#include <iostream>  
#include <string>  
#include <vector> 
#include <regex>
#include <map>
#include <algorithm>
using namespace std;

// 根据正则表达式拆分字符串
vector<string> s_split(const string& in, const string& delim) {
    regex re{ delim };
    return vector<string> {
        sregex_token_iterator(in.begin(), in.end(), re, -1),
        sregex_token_iterator()
    };
}

int main() {
    string s;
    int max = 0, j = 1;
    map<string, int> mp;
    vector<int> vec;
    vector<string> vec_s;
    getline(cin, s);
    auto s_result = s_split(s, "[\\, ]+");
    // copy(s_result.begin(), s_result.end(), ostream_iterator<string>(cout, "\n"));
    for (auto const &i : s_result)
    {
        mp[i]++;
        // aj++;
        if (mp[i] > max)
        {
            // 如果更改值已经存在再vec_s中则将j值重置
            
            max = mp[i];
            vec_s.push_back(i);
            j++;    // 用来记录更改的次数
        }
        else if (mp[i] == max)
        {
            vec_s.push_back(i);
            // j++;    
            // k++;
        }
        // cout << i << ":" << mp[i] << endl;
    }
    cout << j  << endl;
    for (int m = vec_s.size() - j; m < vec_s.size(); m++)
        cout << vec_s[m] << " ";
    cout << endl;
    for (auto &i : vec_s)
        cout << i << " ";
    cout << endl;
    // cout << max_s << endl;
    // cout << s_result[0];
    return 0;
}